package com.augmentum.oes.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.augmentum.oes.dao.QuestionBackupDao;
import com.augmentum.oes.model.QuestionBack;

@Repository
public class QuestionBackupDaoImpl extends BaseDaoImpl implements QuestionBackupDao {

    private static final String MODEL_CLASS_NAME = QuestionBack.class.getName();
    private static final String ADD_PAPER = ".addPaper";
    private static final String RAND_TO_DELETE = ".randToDelete";
    private static final String RAND_TO_ADD = ".randToAdd";

    @Override
    public void save(List<QuestionBack> list) {
        sqlSession.insert(MODEL_CLASS_NAME + ADD_PAPER, list);
    }

    @Override
    public void randToDelete(int id, int row) {
        Map<String, Object> parms = new HashMap<String, Object>();
        parms.put("examid", id);
        parms.put("row", row);
        sqlSession.delete(MODEL_CLASS_NAME + RAND_TO_DELETE, parms);
    }

    @Override
    public void randToAdd(List<QuestionBack> list) {
        sqlSession.delete(MODEL_CLASS_NAME + RAND_TO_ADD, list);
    }
}
